home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_08
/
v7n8075a.txt
< prev
next >
Wrap
Text File
|
1989-10-01
|
1KB
|
56 lines
*****Listing 6*****
#define DOS_IMAGE 1024
unsigned char dos_low_memory[DOS_IMAGE];
unsigned short compute_image_checksum(start,length,copy)
unsigned char * start;
unsigned short length;
unsigned char * copy;
{
unsigned char * end = start + length;
unsigned short sum = 0;
while(start < end)
{
if(copy)
*copy = *start;
sum += *start++;
}
return sum;
}
unsigned short check_image_checksum
(where,start,length,oldsum,copy)
{
unsigned short sum;
unsigned char * end = start + length;
sum = compute_image_checksum(start,length,NULL);
if(sum == oldsum)
return 1;
fprintf(stderr,
"Checksum error at %s: "
"%p/%ud(0x%4x), "
"old %ux, new %ux\n",
where, start, length,
oldsum, sum);
while(start < end)
{
if(*start != *copy)
{
fprintf(stderr,
" %p: old: %02x, new: %02x\n",
start, *copy, *start);
}
}
}
**********